package com.budwk.app.sqfw.controllers.admin.customservice;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.budwk.app.sqfw.services.customservice.RiverChiefService;
import com.budwk.app.sqfw.vo.SqfwCustomForAdminCommonVO;
import com.budwk.starter.common.openapi.annotation.*;
import com.budwk.starter.common.result.Result;
import com.budwk.starter.log.annotation.SLog;
import lombok.extern.slf4j.Slf4j;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.*;

import java.util.List;

/**
 * @BelongsProject: dfxy-shequ
 * @Author: yangweimin
 * @CreateTime: 2024-06-28  16:38
 * @Description: TODO
 */
@IocBean
@At("/platform/sqfw/riverChief")
@ApiDefinition(tag = "河长助手")
@Slf4j
public class RiverChiefForAdminController {
    @Inject
    private RiverChiefService riverChiefService;

    /**
     * 列表查询
     */
    @At()
    @Ok("json")
    @POST
    @ApiOperation(name = "列表查询")
    @ApiFormParams(
            value = {
                    @ApiFormParam(name = "pageNo", example = "1", description = "页码", type = "integer"),
                    @ApiFormParam(name = "pageSize", example = "10", description = "页大小", type = "integer"),
                    @ApiFormParam(name = "pageOrderName", example = "create_date", description = "排序字段"),
                    @ApiFormParam(name = "pageOrderBy", example = "descending", description = "排序方式")
            },
            implementation = SqfwCustomForAdminCommonVO.class
    )
    @ApiResponses(
            implementation = SqfwCustomForAdminCommonVO.class
    )
    @SLog(tag = "公共列表查询（后台管理系统）", value = "${args[0]}}")
    @SaCheckLogin
    public Result<?> list(@Param("..") SqfwCustomForAdminCommonVO bean) {
        return Result.data(riverChiefService.list(bean));
    }

    @At()
    @Ok("json")
    @POST
    @ApiOperation(name = "下载excel")
    @SaCheckLogin
    public Result<?> downExcelByQuery(@Param("..") SqfwCustomForAdminCommonVO bean) {
        return Result.data(riverChiefService.downExcelByQuery(bean));
    }

    @At()
    @Ok("json")
    @POST
    @ApiOperation(name = "下载excel")
    @SaCheckLogin
    public Result<?> downExcel(@Param("idList") List<String> idList) {
        return Result.data(riverChiefService.downExcelByIds(idList));
    }

    @At()
    @Ok("json")
    @GET
    @ApiOperation(name = "获取用户所属区域")
    @SaCheckLogin
    public Result<?> getRegion() {
        return Result.data(riverChiefService.getRegion());
    }

    @At()
    @Ok("json")
    @GET
    @ApiOperation(name = "获取子单位")
    @SaCheckLogin
    public Result<?> getChild(@Param("id") String id) {
        return Result.data(riverChiefService.getChild(id));
    }
}
